<?php

namespace app\lib;


class AppConfig
{
    private $apiData;

    public function __construct()
    {
        $this->setApiData();
    }

    public function setApiData()
    {
        $config = [
            [
                'id' => 1,
                'title' => 'QQ信息',
                'url' => '/api/qqinfo',
                'icon' => '/assets/img/api/qqinfo.svg',
                'alias' => 'qqinfo',
                'desc' => '通过该API可以获取指定QQ账号的基本信息和详细资料, 包括昵称、头像、等级、VIP状态等。',
                'sort' => '生活社交',
                'view' => '1',
                'method' => 'GET',
                'query' => [
                    [
                        'id' => 1,
                        'name' => 'qq',
                        'type' => 'string',
                        'required' => true,
                        'default' => '-',
                        'desc' => 'QQ号码 例如: 12345678'
                    ]
                ],
                'response' => ""
            ],
            [
                'id' => 2,
                'title' => '抖音视频解析',
                'url' => '/api/douyin',
                'icon' => '/assets/img/api/douyin.svg',
                'alias' => 'douyin',
                'desc' => '获取抖音无水印视频，图集',
                'sort' => '站长工具',
                'view' => '1',
                'method' => 'GET',
                'query' => [
                    [
                        'id' => 1,
                        'name' => 'url',
                        'type' => 'string',
                        'required' => true,
                        'default' => '-',
                        'desc' => '抖音的视频URL'
                    ]
                ],
                'response' => ""
            ],
            [
                'id' => 3,
                'title' => 'Privacy | 个人数据泄漏检测',
                'url' => '/api/privacy',
                'icon' => '/assets/img/api/api.svg',
                'alias' => 'privacy',
                'desc' => '个人数据泄漏检测',
                'sort' => '站长工具',
                'view' => '1',
                'method' => 'GET',
                'query' => [
                    [
                        'id' => 1,
                        'name' => 'value',
                        'type' => 'string',
                        'required' => true,
                        'default' => '-',
                        'desc' => 'QQ / 手机号 / 身份证号 / 邮箱 / 微博UID 注意: 如需查询微博UID, 请在输入的UID前面加@。'
                    ]
                ],
                'response' => ""
            ]
        ];

        $this->apiData = $config;
    }

    public function getApiData()
    {
        return $this->apiData;
    }

    public function getApiDataInfo($alias)
    {
        $config = $this->getApiData();
        foreach ($config as $item) {
            if (isset($item['alias']) && $item['alias'] === $alias) {
                return $item;
            }
        }
        return null;
    }
}
